module ext.typetuple;

import std.typetuple;


/***************************************
Returns $(D lst) without items which equal to $(D a).
 */
template staticRemove(alias equal, alias a, lst...)
{
    static if (lst.length)
    {
        static if (equal!(a, lst[0]))
            alias staticRemove!(equal, a, lst[1 .. $]) staticRemove;
        else
            alias TypeTuple!(
                    lst[0], staticRemove!(equal, a, lst[1 .. $]))
                staticRemove;
    }
    else
    {
        alias TypeTuple!() staticRemove;
    }
}


/***************************************
Removes all duplicates in $(D lst).
 */
template staticRemoveDuplicates(alias equal, lst...)
{
    static if (lst.length)
        alias TypeTuple!(
                lst[0], staticRemoveDuplicates!(
                    equal, staticRemove!(equal, lst)))
            staticRemoveDuplicates;
    else
        alias TypeTuple!() staticRemoveDuplicates;
}


